package util

import (
	"fmt"
	"strconv"
	"strings"
)

func JoinInt64(p []int64, sep string) string {
	st := make([]string, len(p))
	for idx, t := range p {
		st[idx] = strconv.FormatInt(t, 10)
	}
	return strings.Join(st, sep)
}

// SqlIDsJoin sql 语句的 id 拼接，FOR IN
func SqlIDsJoin(p []int64) string {
	return JoinInt64(p, ",")
}

// CityCodeWith156 转换为 156 city
func CityCodeWith156(cityCode string) string {
	if strings.HasPrefix(cityCode, "156") {
		return cityCode
	}
	return fmt.Sprintf("156%s", cityCode)
}

// CityCodeWithout156 剔除156
func CityCodeWithout156(cityCode string) string {
	if !strings.HasPrefix(cityCode, "156") {
		return cityCode
	}
	return cityCode[3:]
}
